package com.zbkj.crmeb.store.controller;

import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.common.CommonPage;
import com.common.PageParamRequest;
import com.constants.Constants;
import com.crmeb.core.common.CommonResult;
import com.crmeb.core.exception.CrmebException;
import com.crmeb.core.exception.ExceptionCodeEnum;
import com.utils.CrmebUtil;
import com.utils.ExcelUtil;
import com.utils.OSSUtil;
import com.zbkj.crmeb.chant.dto.ApplyAuditAndSupplierDTO;
import com.zbkj.crmeb.enums.OrderStatusEnum;
import com.zbkj.crmeb.export.vo.DeliveryOrderBatchVo;
import com.zbkj.crmeb.express.vo.LogisticsResultVo;
import com.zbkj.crmeb.front.dto.LabelValueDTO;
import com.zbkj.crmeb.payment.service.OrderPayService;
import com.zbkj.crmeb.store.dao.StoreOrderDao;
import com.zbkj.crmeb.store.model.OrderInfoDeliveryBatchUpload;
import com.zbkj.crmeb.store.model.PurchaseGoods;
import com.zbkj.crmeb.store.model.StoreOrder;
import com.zbkj.crmeb.store.model.StoreOrderInfo;
import com.zbkj.crmeb.store.request.*;
import com.zbkj.crmeb.store.response.StoreOrderInfoResponse;
import com.zbkj.crmeb.store.response.StoreOrderResponse;
import com.zbkj.crmeb.store.response.SupplierOrderResponse;
import com.zbkj.crmeb.store.service.*;
import com.zbkj.crmeb.store.vo.StoreOrderInfoVo;
import com.zbkj.crmeb.system.service.impl.SystemAdminServiceImpl;


/**
 * 字典数据 前端控制器
 */
@RestController
@RequestMapping("api/admin/key/value")
@Api(tags = "字典数据") //配合swagger使用
@Slf4j
public class KeyValueController {
    @Autowired
    private KeyValueService keyValueService;



    @ApiOperation(value = "根据业务类型获取字典数据")
    @RequestMapping(value = "/listByTypeCode", method = RequestMethod.POST)
    public CommonResult<List<LabelValueDTO>> listByTypeCode(@RequestBody @Validated KeyValueRequest request){
        if (null == request) {
            throw new CrmebException("请求数据异常！");
        }
        log.info("根据业务类型获取字典数据，request:{}", JSONObject.toJSONString(request));
        return CommonResult.success(keyValueService.listByTypeCode(request));
    }

    @ApiOperation(value = "根据字典类型数组获取字典数据", notes = "根据字典类型数组获取字典数据", response = String.class)
    @RequestMapping(value = "/listByTypeCodeList", method = RequestMethod.POST)
    public CommonResult<Map<String, List<LabelValueDTO>>> listByTypeCodeList(@RequestBody KeyValueRequest request) {
        if (null == request) {
            throw new CrmebException("请求数据异常！");
        }
        log.info("根据字典类型数组获取字典数据，request:{}", JSONObject.toJSONString(request));
        return CommonResult.success(keyValueService.listByTypeCodeList(request));
    }

}



